<?php
/************************************************************************
Class Pick_Core_Load
----------------------------------------------------------------
PICKCOCMS Project
Company: PICKCO  Co., Ltd 
Name: Nguyen Hai Nam                                  
Last updated: 29/10/2009
**************************************************************************/
class Pick_Core_Load{

	var $path 		= '';
	var $root_path  = ROOT_PATH;
	var $autoLoad	= array();
	
	function Pick_Core_Load() {
		$this->path         = $this->root_path.'libraries';
        $this->path_plusin  = $this->root_path.'plugins';
	}
	function loadClass($class, $type){
		$path = strtolower($this->path . "/" . $type . "/" . $class . ".class.php");
		if(file_exists($path)){
			include_once($this->path . "/core/objects.class.php");
			include_once($path); 
			$obj = new $class();
			if(is_object($obj)){
				return $obj;	
			}
			die("The system can't find class name '$class' in this path '".$path."'.");
		}else{
			die("The path '".$path."' not exist. Please rewiew.");	
		}
	}
	function loadView($data){
		global $template;
		foreach($data as $key=>$value){
			$template->assign($key, $value);	
		}
	}
	function loadPlugins($namePlugins){
            $path = strtolower($this->path_plusin . "/" .  $namePlugins . "/" .  $namePlugins . ".plugins.php");
            if(file_exists($path)){
                include_once($path); 
            }else{
                echo ("The path '".$path."' not exist. Please rewiew.");
                return false;
            }
            return true;
	}
}
?>